<?php

/**
 *    查看物流信息
 *
 *    @author   yanghj 2015-04-02
 *    @usage    none
 */
class Check_shippingApp extends MallbaseApp
{

    function index()
    {
        $typeCom = trim($_GET["com"]);//快递公司
        $typeNu = trim($_GET["nu"]);  //快递单号
        $type = trim($_GET['type']);

        $AppKey='c7c84e4753584217';//在http://kuaidi100.com/app/reg.html申请到的KEY
        $url1 ='http://api.kuaidi100.com/api?id='.$AppKey.'&com='.$typeCom.'&nu='.$typeNu.'&show=0&muti=1&order=asc';
        $url2 = 'http://www.kuaidi100.com/applyurl?key='.$AppKey.'&com='.$typeCom.'&nu='.$typeNu;
        $url = !empty($type) ? $url2 : $url1;

        //请勿删除变量$powered 的信息，否者本站将不再为你提供快递接口服务。
        $powered = '查询数据由：<a href="http://kuaidi100.com" target="_blank">KuaiDi100.Com （快递100）</a> 网站提供 ';


        //优先使用curl模式发送数据
        if (function_exists('curl_init') == 1){
            $curl = curl_init();
            curl_setopt ($curl, CURLOPT_URL, $url);
            curl_setopt ($curl, CURLOPT_HEADER,0);
            curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt ($curl, CURLOPT_USERAGENT,$_SERVER['HTTP_USER_AGENT']);
            curl_setopt ($curl, CURLOPT_TIMEOUT,5);
            $get_content = curl_exec($curl);
            curl_close ($curl);
        }
        $this->assign('data', $get_content);
        $this->display('check_shipping.index.html');
    }

}

?>
